
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 05/19/2012 14:58:18
-- Generated from EDMX file: c:\users\alessandro\documents\visual studio 2010\Projects\TimelineVB\TimelineVB\TimelineDataModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [DBTimeline];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[CalendarSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CalendarSet];
GO
IF OBJECT_ID(N'[dbo].[AvailabilitySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AvailabilitySet];
GO
IF OBJECT_ID(N'[dbo].[MatchSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MatchSet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'CalendarSet'
CREATE TABLE [dbo].[CalendarSet] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [TeamID] int  NOT NULL,
    [TeamName] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'AvailabilitySet'
CREATE TABLE [dbo].[AvailabilitySet] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [CalendarID] int  NOT NULL,
    [DateFrom] datetime  NOT NULL,
    [DateTo] datetime  NOT NULL
);
GO

-- Creating table 'MatchSet'
CREATE TABLE [dbo].[MatchSet] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [DateMatch] datetime  NOT NULL,
    [HomeTeamID] nvarchar(max)  NOT NULL,
    [HomeTeamName] nvarchar(max)  NOT NULL,
    [AwayTeamID] nvarchar(max)  NOT NULL,
    [AwayTeamName] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'CalendarSet'
ALTER TABLE [dbo].[CalendarSet]
ADD CONSTRAINT [PK_CalendarSet]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'AvailabilitySet'
ALTER TABLE [dbo].[AvailabilitySet]
ADD CONSTRAINT [PK_AvailabilitySet]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'MatchSet'
ALTER TABLE [dbo].[MatchSet]
ADD CONSTRAINT [PK_MatchSet]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------